<?php

class Html
{
	/* Limpiar la mierda de feedburner para menear y esas cosas */
	public static function LimpiaBurner($txt)
	{
		return eregi_replace(
			"\<div\>.*(\<a href\=[\"|\']http\:\/\/feeds\.feedburner\.com.*[\"|\']\>.*\<\/a\>.*){2,}\<\/div\>",
			"\n<!-- Feedburner filtrado -->\n",
			$txt);
	}
	
	/* Recortar un html */
	public static function Recorta($txt, $size = 350)
	{
		$txt = strip_tags($txt);
		if(strlen($txt) > $size)
		{
			$txt = substr($txt, 0, $size)."[...]";
		}
		return $txt;
	}
	
	# Limpiar HTML:
	public static function Limpia($html)
	{
		$html = Html::LimpiaBurner($html);
		
		$config = Array(
			"show-body-only" => true,
			"alt-text"       => "Imagen sin descripción",
			"hide-endtags"   => false,
			"output-xhtml"   => true
		);
		$tidy = new tidy;
		$tidy->parseString($html, $config, 'utf8');
		$tidy->cleanRepair();
		
		return $tidy;
	}
}